<?php 
include_once('connection/connection.php');
include('header.php');
include('menu.php');
include('config.php');

//function call for removing blank space from an array
function blanck($var)
{
if($var!="")
{
    return $var;
}
}

//function call for convert id into name
function getName($colName,$id)
{
	$sqlgetName="select distinct ".$colName."_name from tbl_lookup_location where ".$colName."_id in(".$id.")";
	$querygetName=mysql_query($sqlgetName);
	while($rowgetName=mysql_fetch_row($querygetName))
	{
	$name=$name."-".$rowgetName[0];
	}

	$name=explode("-",$name);
	$name=array_filter($name, "blanck");
	return $name=implode($name,",");
}
//fetch all information based on form_id
$frm=$_SESSION['form_id'];
$qr="select * from tbl_dtls_q1_main where form_id='$frm'";
$res=mysql_query($qr);
$row=mysql_fetch_array($res);
$dis=$row['district_id'];
$dis_name=getName('district',$dis);
$_SESSION['dis_name']=$dis_name;
$tehsil=$row['tehsil_id'];
$id1=$row['id'];
$_SESSION['id1']=$id1;
$qr1="select census_subdistrict_name from tbl_lookup_location where district_id='$dis' and census_subdistrict_code='$tehsil'";
$res1=mysql_query($qr1);
$row1=mysql_fetch_array($res1);
if(isset($_POST['back']))
{ 
	header('Location: view_main_q1.php');
}	
if(isset($_POST['submit']))
{ 
	//echo $form_id=$_POST['form_id'];
	//echo $_SESSION['form_id']=$form_id;
	header('Location: view_q1_2.php');
}	
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<title>View Q1</title>
</head>
<body>
<div align="center">
<form action="" method="post" enctype="multipart/form-data">
	<table border="0" width="802" id="table1" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30">
			<p align="center">
			<font face="Verdana" style="font-size: 10pt; font-weight: 700" color="#000000">
			Questionnaire No.1</font></td>
		</tr>
		<tr>
			<td height="19" align="center"><font face="Arial" style="font-size: 8.5pt" color="#000000">(For PHED Officials)</font></td>
		</tr>
		<tr>
			<td align="center"><font face="Arial" style="font-size: 8.5pt" color="#000000">page 1</font></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp;
			<font style="font-size: 8.5pt; font-weight: 700" face="Arial">
			Main Location </font></font>
			</td>
		</tr>
		<tr>
			<td height="66">
				<table border="1" width="805" id="table2" bgcolor="#FDF9EE" cellspacing="1" cellpadding="0" style="border-collapse:collapse; border-color:#99CCCC;">
					<tr>
						<td colspan="4">
							<span style="font-size: 4pt">&nbsp;</span>
						</td>
					</tr>
					<tr>
						<td width="165" height="25">
							<font face="Verdana" style="font-size: 8.5pt" color="#000000"><font color=                            "#FF0000">&nbsp;&nbsp;*</font>District</font>						</td>
						<td width="284"><label id="district"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php $id="$row[district_id]"; echo getName('district',$id);?></font></label></td>
						<td width="117">
							<font face="Verdana" style="font-size: 8.5pt" color="#000000"><font color=                            "#FF0000">*</font>Date&nbsp;&nbsp;</font>						</td>
            			<td width="224"><label id="date"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php echo "$row[date]";?></font></label></td>
					</tr>
					<tr>
						<td width="165" height="28">
							<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;
							<font color="#FF0000">*</font>Block </font>						</td>
						<td width="284"><label id="block"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php $id="$row[block_id]"; echo getName('block',$id);?></font></label></td>
						<td width="117">
							<font face="Verdana" style="font-size: 8.5pt" color="#000000"><font color=                        	"#FF0000">*</font>Revenue &nbsp;&nbsp;Tehsil&nbsp;&nbsp;&nbsp;</font>						</td>
						<td width="224"><label id="tehsil"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php $id="$row[tehsil_id]"; echo "$row1[census_subdistrict_name]"?></font></label></td>
			    	</tr>
			  </table>
		  </td>
		</tr>
		<tr>
			<td><span style="font-size: 4pt">&nbsp;</span></td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp;
				</font><span style="font-weight: 700">
				<font face="Arial" style="font-size: 8.5pt" color="#000000">1. Scheme 
				Details</font></span>
			</td>
		</tr>
		<tr>
			<td><span style="font-size: 3pt">&nbsp;</span></td>
		</tr>
		<tr>
			<td>
			<table width="800" height="159" border="1" cellpadding="0" cellspacing="1" bgcolor="#FDF9EE" id="table6" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
					<td height="9" colspan="2"><span style="font-size: 4pt">&nbsp;</span></td>
				</tr>
				<tr>
					<td width="270" height="28">&nbsp;
						<font style="font-size: 8.5pt" face="Verdana" color="#000000">
						Type of the Scheme (As of Now)</font>					</td>
					<td width="477"><label id="type_scheme"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[type_scheme]";?></font></label></td>
				</tr>
				
				<tr>
					<td width="270" height="26">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
						Name of the Schemes </font></td>
					<td width="477"><label id="name_scheme"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[name_scheme]";?></font></label></td>
				</tr>
				<tr>
					<td width="270" height="28">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
						Year of Commissioning</font></td>
					<td width="477"><label id="year_comm"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[year_comm]";?></font></label></td>
				</tr>
				<tr>
					<td width="270" height="28">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
						Capital Cost (in <img src="images/26rup1.jpg" width="10"> Lakh)</font></td>
						<!--<font face="Rupee Foradian" size="3">`</font>-->
					<td width="477"><label id="capital_cost"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[capital_cost]";?></font></label></td>
				</tr>
				<tr>
					<td width="270" height="31">&nbsp;
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">
						Schemes Sanctioned Under </font>					</td>
					<td width="477"><label id="scheme_sactioned"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[scheme_sactioned]";?></font></label></td>
			  </tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<span style="font-size: 5pt">&nbsp;</span>
		</td>
	</tr>
	<tr>
		<td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp;
			<font style="font-size: 8.5pt; font-weight: 700" face="Arial">
			2. Location </font></font>
		</td>
	</tr>
	<tr>
		<td>
			<table border="1" width="800" id="table7" bgcolor="#FDF9EE" cellspacing="2" cellpadding="2" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
					<td height="11" colspan="4">
						<span style="font-size: 4pt">&nbsp;</span></td>
				</tr>
				<tr>
					<td width="287" height="29">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;&nbsp;<font color="#FF0000">*</font>Grampanchayat</font>					</td>
					<td width="504"><label id="gp"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php  $id="$row[panchayat_id]"; echo wordwrap(getName('panchayat',$id), 20, "\n", true);?></label></td>
				</tr>
				<tr>
					<td width="287">&nbsp;
						<font style="font-size: 8.5pt" face="Verdana" color="#000000"><font color="#FF0000">*</font>Village (s) Covered Names &nbsp;&nbsp;&nbsp;(MH)</font></td>
					<td width="504"><label id="village"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php $id="$row[village_id]"; echo wordwrap(getName('village',$id), 20, "\n", true);?></label></td>
				</tr>
				<tr>
					<td width="287" height="24">&nbsp;
						<font style="font-size: 8.5pt" face="Verdana" color="#000000"><font color="#FF0000">*</font>Form Id</font></td>
					<td width="504"><label id="formid"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php echo "$row[form_id]";?></font></label></td>
				</tr>
				<tr>
					<td width="287" height="28">&nbsp;
						<font style="font-size: 8.5pt" face="Verdana" color="#000000"><font color="#FF0000">*</font>Census Village Code</font></td>
					<td width="504"><label id="census"><font face="Verdana" style="font-size: 8.5pt">&nbsp;<?php echo wordwrap($row['cvc'], 20, "\n", true);?></font></label></td>
				</tr>
				<tr>
					<td colspan="4" bgcolor="#EEEEEE">&nbsp;
					<font style="font-size: 8.5pt; font-weight: 700" face="Arial" color="#000000">
					3.Other Habitations (OH) covered</font></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table border="1" width="800" id="table4" cellspacing="1" cellpadding="0" bgcolor="#FDF9EE" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
					<td colspan="3"><span style="font-size: 4pt">&nbsp;</span></td>
				</tr>
				<tr>
					<td align="center" width="31%" bgcolor="#F7E6B7" height="36">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">                       Name of OH</font></td>
					<td align="center" width="24%" bgcolor="#F7E6B7" height="36">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">
						Code No. (As per IMIS)</font></td>
						<td align="center" width="17%" rowspan="" bgcolor="#F7E6B7">
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">Type MH/ OH</font></td>
					<td align="center" width="28%" bgcolor="#F7E6B7" height="36">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">
						Actual Status at Site (E/NT)</font></td>
				</tr>	
				<?php
				//fetch all habitation list from q1 using order by habitation code
				$qr2="select distinct habit_name,habit_code,type_habit,status_e_nt from tbl_dtls_q1_oh where loc_id='".$id1."' order by habit_code asc";
				$res2=mysql_query($qr2);
				while($row2=mysql_fetch_array($res2))
				{
				?>
				 <tr>
				<td width="31%" height="23" align="center"><label id="habit_name"><font face="Verdana" style="font-size: 8.5pt"><?php echo "$row2[habit_name]";?></font></label></td>
				<td width="24%" align="center"><label id="habit_code"><font face="Verdana" style="font-size: 8.5pt"><?php echo "$row2[habit_code]";?></font></label></td>
			   	<td align="center" width="17%"><label id="type_habit"><font face="Verdana" style="font-size: 8.5pt"><?php echo "$row2[type_habit]";?></font></label></td>
				<td width="28%" align="center"><label id="status_e_nt"><font face="Verdana" style="font-size: 8.5pt"><?php echo "$row2[status_e_nt]";?></font></label></td>
				</tr>
			<?php } ?>
			</table>
		</td>
	</tr>
	<tr>
		<td><div id="habit"></div></td>
	</tr>
	
	<tr>
		  <td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp; <font style="font-size: 8.5pt; font-weight: 700" face="Arial">No. of Unlisted Habitation</font></font></td>
		</tr>
		<tr><td>
		<table border="1" cellspacing="0" cellpadding="0" bgcolor="#FDF9EE" style="border-collapse:collapse; border-color:#99CCCC;">
		<tr><td width="230px" align="center" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#990000">Unlisted Habitation Name</font></td></tr>
		       <?php
			   //fetch unhabitation list from q1
				$qrUnhabit="select * from tbl_dtls_q1_unhabit where loc_id='$id1'";
				$resUnhabit=mysql_query($qrUnhabit);
				while($rowUnhabit=mysql_fetch_array($resUnhabit))
				{
				?>
		<tr><td><label id="unhabit1"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowUnhabit[unhabit_name]";?></font></label></td></tr>
		<?php
		}
		?>
		</table>
		</td></tr>
	
	<tr>
		<td width="802" bgcolor="#EEEEEE">&nbsp;
			<span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">4. Population</font></span></td>
	</tr>
	<tr>
		<td>
			<table border="1" width="800" id="table8" bgcolor="#FDF9EE" cellspacing="1" cellpadding="0" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
					<td colspan="4">
						<span style="font-size: 4pt">&nbsp;</span>					</td>
				</tr>
				<tr>
				
					<td width="241" align="center">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000"> 
						Population Benefited  <br>
						(as per 2001 census)</font></td>
					<td width="191" align="center"><label id="population_benefited"><font face="Arial" style="font-size: 8.5pt">&nbsp;<?php echo "$row[population_benefited]";?></font></label></td>
					<td width="133" align="center">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">
						Present Population&nbsp;&nbsp;&nbsp; </font></td>
				  <td width="220" align="center"><label id="present_population"><font face="Arial" style="font-size: 8.5pt">&nbsp;<?php echo "$row[present_population]";?></font></label></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="802" bgcolor="#EEEEEE">&nbsp;<span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">5. Sources of Water Supply</font></span>		</td>
	</tr>
	<tr>
		<td colspan="6">
			<table border="1" width="800" id="table10" bgcolor="#FDF9EE" cellspacing="1" cellpadding="0" style="border-collapse:collapse; border-color:#99CCCC;">
				
				
				<tr>
					<td width="2980" colspan="4">&nbsp;<font style="font-size: 8.5pt" face="Verdana" color="#000000"> Source Details-</font></td>
				</tr>
				<tr>
					<td colspan="6"><table border="1" width="800" id="table4" cellspacing="1" cellpadding="0" bgcolor="#FDF9EE" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
				<td align="center" width="190" bgcolor="#F7E6B7">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">Source</font></td>
					<td align="center" width="174" bgcolor="#F7E6B7">
                        <font face="Verdana" style="font-size: 8.5pt" color="#990000">Current Status</font>                    </td>
						
					<td align="center" width="74" bgcolor="#F7E6B7">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">
						Yield (Min) KL/day</font></td>
					<td align="center" width="92" bgcolor="#F7E6B7">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">
						Yield (Max) KL/day</font></td>
					<td align="center" width="120" bgcolor="#F7E6B7">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">Water Table (Min) (M)</font></td>
					<td align="center" width="143" bgcolor="#F7E6B7">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">
						Water Table (Max) (M)</font></td>
				</tr>	
				<?php
				$qr2="select * from tbl_dtls_q1_sws where loc_id='$id1'";
				$res2=mysql_query($qr2);
				while($rowSws=mysql_fetch_array($res2))
				{
				?>
				<tr align="center">
					<td width="190" align="center"><label id="source"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[source]";?></font></label></td>
				  	<td width="174" height="20"><label id="current_status"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[current_status]";?></font></label></td>
					<td width="74" align="center"><label id="yield_min"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[yield_min]";?></font></label></td>
					<td width="92" align="center"><label id="yield_max"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[yield_max]";?></font></label></td>
					<td width="120" align="center"><label id="water_table_min"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[water_table_min]";?></font></label></td>
					<td width="143" align="center"><label id="water_table_max"><font style="font-size: 8.5pt" face="Verdana"><?php echo "$rowSws[water_table_max]";?></font></label></td>
				</tr>
<?php 
 }
?>
</table></td></tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="802" bgcolor="#EEEEEE">&nbsp;
			<span style="font-weight: 700"><font face="Arial" style="font-size: 8.5pt" color="#000000">6. Hand pumps &amp; Single Phase pumps installed (on above	mentioned if any)            </font></span>		</td>
	</tr>
	<tr>
		<td height="57">
			<table border="1" width="800" id="table11" bgcolor="#FDF9EE" cellspacing="1" cellpadding="0" style="border-collapse:collapse; border-color:#99CCCC;">
				<tr>
					<td colspan="2"><span style="font-size: 4pt">&nbsp;</span></td>
				</tr>
				<tr>
					<td width="189" height="21">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
						HP Nos.</font>					</td>
					<td width="602"><label id="hp_nos"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[hp_nos]";?></font></label></td>
				</tr>
				<tr>
					<td width="189" height="21">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
						SP Nos.</font>					</td>
					<td width="602"><label id="sp_nos"><font style="font-size: 8.5pt" face="Verdana">&nbsp;<?php echo "$row[sp_nos]";?></font></label></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>
			<p align="center">
			<input type="submit" value="Back" name="back" style="font-size: 8pt;font-family:Verdana; border-style: solid; border-width: 1px">&nbsp;&nbsp;
			<input type="submit" value="Next" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px" onClick="return validate1()">&nbsp;</p>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
</table>
</form>		
</div>
</body>
</html>